package com.example.demo.repository;

import com.example.demo.domain.AnalyseGood;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;


@Mapper
@Repository
public interface AnalyseMapper {

    Double getProfitByMonth(@Param("start")String start,@Param("end")String end);

    @Select("select sum(goodsNum) totalNum,sum(selling_price*goodsNum) totalSell,sum(buying_price*goodsNum) totalCost," +
            "sum((selling_price-buying_price)*goodsNum) totalProfit from orders where state=3 and gid=#{gid} " +
            "and times >= #{start} and times <= #{end}")
    AnalyseGood getAnalyseGood(@Param("gid")Integer gid,@Param("start")String start,@Param("end")String end);
}
